import 'package:baselib/base/base_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:moduletwo/module/viewmodel/get_one_view_model.dart';

class GetOnePage extends StatefulWidget {
  @override
  _GetOnePageState createState() => _GetOnePageState();
}

class _GetOnePageState extends State<GetOnePage> {

  @override
  Widget build(BuildContext context) {
    print('build-->');
    return BaseView<GetOneViewModel>(
      model:GetOneViewModel() ,
      builder: (controller){
        return _buildPageUi(controller);
      },
    );
  }


  Widget _buildPageUi(GetOneViewModel model) {
    return Scaffold(
      appBar: AppBar(
        title: Text('GetOnePage'),
      ),
      body: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text('${model.count.obs}'),
          Obx((){
            print('_buildPageUi-->count=${model.count}');
            return Text('${model.count.value}');
          }),
          SizedBox(height: 30,),
          FlatButton(onPressed: ()=>model?.toNextPage(), child: Text('点击进入下一页'),color: Colors.blue,),
          FlatButton(onPressed: ()=>model.increase(), child: Text('点击相加'),color: Colors.amber,)
        ],
      ),
    );
  }
}
